package com.dayuanit.dy16.ebook.ebookweb.controller;

import com.dayuanit.dy16.ebook.ebookweb.dto.ResponseDTO;
import com.dayuanit.dy16.ebook.ebookweb.service.INavService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IndexController extends BaseController {

    @Autowired
    private INavService navService;

    @RequestMapping("/loadNav")
    public ResponseDTO loadNav() {
        return ResponseDTO.success(navService.loadNav());
    }

    @RequestMapping("/loadNavCommoditys")
    public ResponseDTO loadNavCommoditys(long navId) {
        return ResponseDTO.success(navService.loadNavCommodity(navId));
    }


    @RequestMapping("/loadCommodity")
    public ResponseDTO loadCommodity(long commoId) {
        return ResponseDTO.success(navService.loadCommodity(commoId));
    }

    @RequestMapping(value = "/book/{bookId}/{picId}", method = RequestMethod.GET)
    public ResponseDTO getBook(@PathVariable("bookId") String bookId, @PathVariable("picId") int picId) {
        System.out.println("bookId=" + bookId);
        System.out.println("picId=" + picId);
        return null;
    }

    @RequestMapping(value = "/book/1001", method = RequestMethod.DELETE)
    public ResponseDTO delBook() {
        return null;
    }
}
